package com.ces.knacky.controller.tools;

import java.util.Date;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import com.ces.knacky.framework.controller.BaseController;
import com.ces.knacky.framework.model.IEntity;
import com.ces.knacky.model.Brand;
import com.ces.knacky.model.Flag;
import com.ces.knacky.model.UserTable;
@Controller
public class SaveBrandController extends BaseController {
	
	private String name;
	
	private String description;
	
	private Float expectedPrice;
	
	@RequestMapping ("/saveBrand.htm")	
	public String execute(){
		System.out.println("Inside Save Brand");
		Brand brand = new Brand();
		brand.setDescription(description);
		brand.setCreateTime(new Date());
		brand.setUpdateTime(new Date());
		IEntity entity = commonService.findFirstByDescription(UserTable.class, "admin");
		brand.setUser((UserTable)entity);
		entity = commonService.findFirstByDescription(Flag.class, "ACTIVE");
		brand.setFlag((Flag)entity);
		commonService.add(brand);
		return "saveBrand";
	}
	

	/**
	 * @return the description
	 */	
	public String getDescription() {
		return description;
	}

	/**
	 * @param description the description to set
	 */
	@ModelAttribute("description")
	public void setDescription(String description) {
		this.description = description;
	}


}
